﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BF.IBLL.BaseSystem;
using Base.Core.UnityFactory;
using BF.Model;
using BF.Infrastructure;
using System.Text;
using Ext.Net;
using System.Web.Security;

namespace BF.Web.pages
{
    public partial class defaultMain : BasePage
    {
        int lastId = 0;
        public string GetLastID()
        {
            lastId++;
            return "MyControls" + lastId;
        }

        public string UserType
        {
            get
            {
                string temp = string.Empty;

                return temp;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {



            if (!IsPostBack)
            {
                ////通告
                //notification();
                BindMenu();
                this.litUserName.Text = String.Format("欢迎您：{0}【昵称：{1}】", User.Identity.Name, GetSessionCurrentUserInfo.sUserName);
                this.litHospital.Text = String.Format("【机构：{0}】", GetSessionCurrentUserInfo.dic_Organization == null ? "" : GetSessionCurrentUserInfo.dic_Organization.sOrganizationName);
                //BindDefault();
            }
        }

        #region 生成左则菜单
        private List<sys_Function> MenuDs
        {
            set
            {
                ViewState["menuSet"] = value;
            }
            get
            {
                if (ViewState["menuSet"] == null)
                {
                    ViewState["menuSet"] = GetAllMenu();
                }
                return ViewState["menuSet"] as List<sys_Function>;
            }
        }


        /// <summary>
        /// 获得菜单列表
        /// </summary>
        public List<sys_Function> GetAllMenu()
        {

            Isys_PermissionBLL iBLL =
                IOCFactory.GetIOCResolve<Isys_PermissionBLL>();
            Isys_UserInfoBLL iUserInfoBLL =
                IOCFactory.GetIOCResolve<Isys_UserInfoBLL>();
            sys_UserInfo userInfo = iUserInfoBLL
                .GetModelByloginname(User.Identity.Name);

            List<sys_Function> list = new List<sys_Function>();
            if (User.Identity.Name == "admin")
            {
                list = iBLL.GetFunctionListByAdmin();
            }
            else
            {
                list = iBLL
                .GetFunctionListByUserID(userInfo.gUserID.ToString());
            }

            return list.Where(P => P.iType == 1 || P.iType == 2)
                .Where(P => P.bIsShow == true)
                .ToList();
        }

        #endregion

        #region 手风琴格式

        #region 绑定一级菜单，并且实现递归

        /// <summary>
        /// 绑定一级菜单，并且实现递归
        /// </summary>
        /// <param name="ds"></param>
        private void BindMenu()
        {
            //注意根据实际情况这个vAMParent定为1.
            var sysTitle = MenuDs.Where(p => p.iLevel == 1)
                .OrderBy(p => p.iSort)
                .Select(
                    p => new
                    {
                        id = p.gKey.ToString(),
                        nodeName = p.sName,
                        url = p.sPath,
                        parentId = p.gParentKey.ToString(),
                        iconCls = p.sIconCls
                    });
            foreach (var item in sysTitle)
            {
                int chileCount = MenuDs
                    .Where(p => p.gParentKey == new Guid(item.id))
                    .Count();
                if (chileCount != 0)
                {
                    Ext.Net.TreePanel comp =
                        new Ext.Net.TreePanel() { ID = GetLastID() };
                    comp.Title = item.nodeName;
                    comp.IconCls = item.iconCls;
                    comp.RootVisible = false;
                    comp.AutoScroll = true;
                    comp.SingleExpand = true;
                    comp.UseArrows = true;
                    comp.Lines = false;
                    CreateSystemMenu(item.id, ref comp);
                    West.Items.Add(comp);
                    comp.Collapsed = false; //是否折叠

                }
            }
        }

        #endregion


        #region 直接TreePanel下级菜单（2级菜单）
        //直接TreePanel下级菜单（2级菜单）
        private void CreateSystemMenu(string pid,
            ref Ext.Net.TreePanel comp)
        {
            var sysTitle = MenuDs
                .Where(p => p.gParentKey == new Guid(pid))
                .OrderBy(p => p.iSort)
                .Select(
                    p => new
                    {
                        id = p.gKey.ToString(),
                        nodeName = p.sName,
                        url = p.sPath,
                        parentId = p.gParentKey.Value.ToString(),
                        iconCls = p.sIconCls
                    });

            Ext.Net.TreeNode root = new Ext.Net.TreeNode();//根节点

            foreach (var item in sysTitle)
            {
                Ext.Net.TreeNode tmpNode =
                    new Ext.Net.TreeNode()
                    {
                        NodeID = GetLastID(),
                        Text = item.nodeName,
                        IconCls = item.iconCls,
                        SingleClickExpand = true,
                    };

                int chileCount = MenuDs
                    .Where(p => p.gParentKey == new Guid(item.id))
                    .Count();
                if (chileCount != 0)
                {
                    //3级菜单或更下级菜单
                    CreateSystemMenu(item.id, ref tmpNode);
                }
                else
                {
                    tmpNode.Listeners.Click.Handler =
                        "addTab(#{Pages},'"
                        + item.nodeName
                        + "' , '"
                        + item.url
                        + "','');";
                }
                root.Nodes.Add(tmpNode);

            }
            comp.Root.Add(root);
        }

        #endregion

        #region 创建左侧菜单栏（3级菜单以后）
        /// <summary>
        /// 创建左侧菜单栏（3级菜单以后）
        /// </summary>
        protected void CreateSystemMenu(string parentId,
            ref  Ext.Net.TreeNode parentItem)
        {
            var sysTitle = MenuDs
                .Where(p => p.gParentKey == new Guid(parentId))
                .OrderBy(p => p.iSort)
                .Select(
                    p => new
                    {
                        id = p.gKey.ToString(),
                        nodeName = p.sName,
                        url = p.sPath,
                        parentId = p.gParentKey.Value.ToString(),
                        iconCls = p.sIconCls
                    });
            foreach (var item in sysTitle)
            {
                Ext.Net.TreeNode tmpMp = new Ext.Net.TreeNode()
                {
                    NodeID = GetLastID(),
                    Text = item.nodeName,
                    IconCls = item.iconCls,
                    SingleClickExpand = true,
                };

                int chileCount = MenuDs
                    .Where(p => p.gParentKey == new Guid(item.id))
                    .Count();
                if (chileCount != 0)
                {
                    //3级菜单或更下级菜单
                    CreateSystemMenu(item.id, ref tmpMp);
                }
                else
                {
                    tmpMp.Listeners.Click.Handler =
                        "addTab(#{Pages},'"
                        + item.nodeName
                        + "' , '"
                        + item.url
                        + "','');";
                }
                parentItem.Nodes.Add(tmpMp);
            }
        }

        #endregion

        #endregion

        #region 绑定首页内容
        private string SubStringZero(string str)
        {
            int index = str.IndexOf("00", 4);
            if (index != -1)
                return str.Substring(0, 4);
            return str;
        }

        //private void BindDefault()
        //{
        //    string sSetAreaCode = GetSysParam("AreaCode");
        //    //  string sAreaCode = (GetSessionCurrentUserInfo.dic_Hospital == null ? sSetAreaCode : GetSessionCurrentUserInfo.dic_Hospital.sDivisionCode);
        //    string sAreaCodeSub = SubStringZero(sSetAreaCode);
        //    //文章类型：1 领导活动，2 通知公告，3 通报，4 工作简讯，5 政策法规，6 地方工作动态，7 系统升级报告 8 公文公开
        //    string temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";

        //    string url2 = "addTab(#{Pages},'领导活动列表' , '/pages/BaseSystem/OANewsManagement/MoreDocumentInfoList.aspx?iType=1','');";

        //    List<sys_OANews> list = new List<sys_OANews>();
        //    //res_HumanResources res_humanResmodel = new res_HumanResources();
        //    //res_humanResmodel = HumanResourcesbll.GetModelByCondition(P => P.gUserID == GetSessionCurrentUserInfo.gUserID);
        //    //if (res_humanResmodel == null)
        //    if (false)
        //    {

        //    }
        //    else
        //    {
        //        if (GetSessionCurrentUserInfo.dic_Hospital != null)
        //        {
        //            list = iBLLOANews.GetList(
        //             P => (
        //                 (P.iType == 1)
        //                 && (P.iflag == 1)
        //                 //&& (P.bIsAllUnit == true || P.sys_OANewsTagUnit.Where(Q => Q.gTagUnitKey == res_humanResmodel.gKey).Count() > 0)
        //                 )
        //                 ,
        //             P => new
        //             {
        //                 P.dPublishTime
        //             },
        //             new PageModel(1), false);
        //        }
        //        else
        //        {
        //            list = iBLLOANews.GetList(
        //            P => (
        //             (P.iType == 1)
        //             && (P.iflag == 1)
        //             )
        //             ,
        //            P => new
        //            {
        //                P.dPublishTime
        //            },
        //         new PageModel(1), false);
        //        }


        //        for (int i = 0; i < 4; i++)
        //        {
        //            if (i < list.Count)
        //            {
        //                string gKey = list[i].gKey.ToString();
        //                string url = "addTab(#{Pages},'领导活动' , '/pages/BaseSystem/OANewsManagement/DocumentInfoView.aspx?source=defaultMain&gKey=" + gKey + "','');";
        //                string temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + list[i].sTitle + "\" onclick=\"" + url + "\">" + (list[i].sTitle.Length > 16 ? (list[i].sTitle.Substring(0, 16) + "...") : list[i].sTitle) + "</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">" + (list[i].dPublishTime == null ? "" : ("[" + list[i].dPublishTime.Value.ToString("yyyy-MM-dd") + "]")) + "</td></tr>";
        //                temp_czgg += temp_gg;
        //            }
        //        }
        //        Portlet1.Html = temp_czgg + "</table>";

        //        Portlet1.Title = "<div style=\"color:#000000;float:left;\">领导活动</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + url2 + "\">更多</a></div>";

        //        //通知公告
        //        if (GetSessionCurrentUserInfo.dic_Hospital != null)
        //        {
        //            list = iBLLOANews.GetList(
        //                             P => (
        //                                 (P.iType == 2)
        //                                 && (P.iflag == 1)
        //                                 //&& (P.bIsAllUnit == true || P.sys_OANewsTagUnit.Where(Q => Q.gTagUnitKey == res_humanResmodel.gKey).Count() > 0)

        //                                 ),
        //                             P => new
        //                             {
        //                                 P.dPublishTime
        //                             },
        //                             new PageModel(1), false);
        //        }
        //        else
        //        {
        //            list = iBLLOANews.GetList(
        //              P => (
        //                  (P.iType == 2)
        //                  && (P.iflag == 1)
        //                  ),
        //              P => new
        //              {
        //                  P.dPublishTime
        //              },
        //              new PageModel(1), false);
        //        }
        //        temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";
        //        for (int i = 0; i < 3; i++)
        //        {
        //            if (i < list.Count)
        //            {
        //                string gKey = list[i].gKey.ToString();
        //                string url = "addTab(#{Pages},'通知公告' , '/pages/BaseSystem/OANewsManagement/DocumentInfoView.aspx?source=defaultMain&gKey=" + gKey + "','');";
        //                string temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + list[i].sTitle + "\" onclick=\"" + url + "\">" + (list[i].sTitle.Length > 16 ? (list[i].sTitle.Substring(0, 16) + "...") : list[i].sTitle) + "</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">" + (list[i].dPublishTime == null ? "" : ("[" + list[i].dPublishTime.Value.ToString("yyyy-MM-dd") + "]")) + "</td></tr>";
        //                temp_czgg += temp_gg;
        //            }
        //        }
        //        Portlet2.Html = temp_czgg + "</table>";
        //        url2 = "addTab(#{Pages},'通知公告列表' , '/pages/BaseSystem/OANewsManagement/MoreDocumentInfoList.aspx?iType=2','');";
        //        Portlet2.Title = "<div style=\"color:#000000;float:left;\">通知公告</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + url2 + "\">更多</a></div>";

        //        //通报
        //        if (GetSessionCurrentUserInfo.dic_Hospital != null)
        //        {
        //            list = iBLLOANews.GetList(
        //                             P => ((P.iType == 3) && (P.iflag == 1)
        //                                 //&& (P.bIsAllUnit == true
        //                                 //|| P.sys_OANewsTagUnit.Where(Q => Q.gTagUnitKey == res_humanResmodel.gKey).Count() > 0)
        //                                 ),
        //                             P => new
        //                             {
        //                                 P.dPublishTime
        //                             },
        //                             new PageModel(1), false);
        //        }
        //        else
        //        {
        //            list = iBLLOANews.GetList(
        //                             P => ((P.iType == 3) && (P.iflag == 1)),
        //                             P => new
        //                             {
        //                                 P.dPublishTime
        //                             },
        //                             new PageModel(1), false);
        //        }
        //        temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";
        //        for (int i = 0; i < 3; i++)
        //        {
        //            if (i < list.Count)
        //            {
        //                string gKey = list[i].gKey.ToString();
        //                string url = "addTab(#{Pages},'通报' , '/pages/BaseSystem/OANewsManagement/DocumentInfoView.aspx?source=defaultMain&gKey=" + gKey + "','');";
        //                string temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + list[i].sTitle + "\" onclick=\"" + url + "\">" + (list[i].sTitle.Length > 16 ? (list[i].sTitle.Substring(0, 16) + "...") : list[i].sTitle) + "</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">" + (list[i].dPublishTime == null ? "" : ("[" + list[i].dPublishTime.Value.ToString("yyyy-MM-dd") + "]")) + "</td></tr>";
        //                temp_czgg += temp_gg;
        //            }
        //        }
        //        Portlet3.Html = temp_czgg + "</table>";
        //        url2 = "addTab(#{Pages},'通报列表' , '/pages/BaseSystem/OANewsManagement/MoreDocumentInfoList.aspx?iType=3','');";
        //        Portlet3.Title = "<div style=\"color:#000000;float:left;\">通报</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + url2 + "\">更多</a></div>";

        //        //工作简讯
        //        //if (GetSessionCurrentUserInfo.dic_Hospital != null)
        //        //{
        //        //    list = iBLLOANews.GetList(
        //        //                     P => ((P.iType == 4)
        //        //                         && (P.iflag == 1)
        //        //                         && (P.bIsAllUnit == true ||
        //        //                         P.sys_OANewsTagUnit.Where(Q => Q.gTagUnitKey == res_humanResmodel.gKey).Count() > 0)
        //        //                         ),
        //        //                     P => new
        //        //                     {
        //        //                         P.dPublishTime
        //        //                     },
        //        //                     new PageModel(1), false);
        //        //}
        //        //else
        //        //{
        //        //    list = iBLLOANews.GetList(
        //        //     P => ((P.iType == 4) && (P.iflag == 1)),
        //        //     P => new
        //        //     {
        //        //         P.dPublishTime
        //        //     },
        //        //     new PageModel(1), false);
        //        //}


        //        //temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";
        //        //for (int i = 0; i < 5; i++)
        //        //{
        //        //    if (i < list.Count)
        //        //    {
        //        //        string gKey = list[i].gKey.ToString();
        //        //        string url = "addTab(#{Pages},'工作简讯' , '/pages/BaseSystem/OANewsManagement/DocumentInfoView.aspx?source=defaultMain&gKey=" + gKey + "','');";
        //        //        string temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + list[i].sTitle + "\" onclick=\"" + url + "\">" + (list[i].sTitle.Length > 16 ? (list[i].sTitle.Substring(0, 16) + "...") : list[i].sTitle) + "</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">" + (list[i].dPublishTime == null ? "" : ("[" + list[i].dPublishTime.Value.ToString("yyyy-MM-dd") + "]")) + "</td></tr>";
        //        //        temp_czgg += temp_gg;
        //        //    }
        //        //}

        //        //政策法规
        //        if (GetSessionCurrentUserInfo.dic_Hospital != null)
        //        {
        //            list = iBLLOANews.GetList(
        //                             P => ((P.iType == 5)
        //                                 && (P.iflag == 1)
        //                                 //&& (P.bIsAllUnit == true ||
        //                                 //P.sys_OANewsTagUnit.Where(Q => Q.gTagUnitKey == res_humanResmodel.gKey)
        //                                 //.Count() > 0)
        //                                  ),
        //                             P => new
        //                             {
        //                                 P.dPublishTime
        //                             },
        //                             new PageModel(1), false);
        //        }
        //        else
        //        {
        //            list = iBLLOANews.GetList(
        //             P => ((P.iType == 5) && (P.iflag == 1)),
        //             P => new
        //             {
        //                 P.dPublishTime
        //             },
        //             new PageModel(1), false);
        //        }
        //        temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";
        //        for (int i = 0; i < 3; i++)
        //        {
        //            if (i < list.Count)
        //            {
        //                string gKey = list[i].gKey.ToString();
        //                string url = "addTab(#{Pages},'政策法规' , '/pages/BaseSystem/OANewsManagement/DocumentInfoView.aspx?source=defaultMain&gKey=" + gKey + "','');";
        //                string temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + list[i].sTitle + "\" onclick=\"" + url + "\">" + (list[i].sTitle.Length > 16 ? (list[i].sTitle.Substring(0, 16) + "...") : list[i].sTitle) + "</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">" + (list[i].dPublishTime == null ? "" : ("[" + list[i].dPublishTime.Value.ToString("yyyy-MM-dd") + "]")) + "</td></tr>";
        //                temp_czgg += temp_gg;
        //            }
        //        }
        //        Portlet5.Html = temp_czgg + "</table>";
        //        url2 = "addTab(#{Pages},'政策法规列表' , '/pages/BaseSystem/OANewsManagement/MoreDocumentInfoList.aspx?iType=5','');";
        //        Portlet5.Title = "<div style=\"color:#000000;float:left;\">政策法规</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + url2 + "\">更多</a></div>";


        //        //地方工作动态
        //        if (GetSessionCurrentUserInfo.dic_Hospital != null)
        //        {
        //            list = iBLLOANews.GetList(
        //                             P => ((P.iType == 6) && (P.iflag == 1)
        //                              && P.bIfSubmit == true
        //                              && (P.sAreaCode.Contains(sAreaCodeSub))
        //                                 //&& (P.bIsAllUnit == true || P.sys_OANewsTagUnit.Where(Q => Q.gTagUnitKey == res_humanResmodel.gKey).Count() > 0)
        //                              )
        //                              ,
        //                             P => new
        //                             {
        //                                 P.dPublishTime
        //                             },
        //                             new PageModel(1), false);
        //        }
        //        else
        //        {

        //            list = iBLLOANews.GetList(
        //                             P => ((P.iType == 6) && (P.iflag == 1)
        //                              && P.bIfSubmit == true
        //                              && (P.sAreaCode.Contains(sAreaCodeSub))
        //                                 ),
        //                             P => new
        //                             {
        //                                 P.dPublishTime
        //                             },
        //                             new PageModel(1), false);
        //        }
        //        temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";
        //        for (int i = 0; i < 3; i++)
        //        {
        //            if (i < list.Count)
        //            {
        //                string gKey = list[i].gKey.ToString();
        //                string url = "addTab(#{Pages},'地方工作动态' , '/pages/BaseSystem/OANewsManagement/PlaceWorkView.aspx?source=defaultMain&gKey=" + gKey + "','');";
        //                string temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + list[i].sTitle + "\" onclick=\"" + url + "\">" + (list[i].sTitle.Length > 16 ? (list[i].sTitle.Substring(0, 16) + "...") : list[i].sTitle) + "</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">" + (list[i].dPublishTime == null ? "" : ("[" + list[i].dPublishTime.Value.ToString("yyyy-MM-dd") + "]")) + "</td></tr>";
        //                temp_czgg += temp_gg;
        //            }
        //        }
        //        Portlet6.Html = temp_czgg + "</table>";
        //        url2 = "addTab(#{Pages},'地方工作动态列表' , '/pages/BaseSystem/OANewsManagement/PlaceWorkList.aspx?flag=more','');";
        //        Portlet6.Title = "<div style=\"color:#000000;float:left;\">地方工作动态</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + url2 + "\">更多</a></div>";
        //    }

        //    String weather_more = GetConfigByName("weather_more"); //更多天气预报url
        //    String weather = GetConfigByName("weather");//天气预报url
        //    Portlet4.Title = "<div style=\"color:#000000;float:left;\">天气预报</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"http://www.weather.com.cn/weather/" + GetSysParam("weatherID") + ".shtml\" target=\"_blank\">更多</a></div>";
        //    Portlet4.Html = "<iframe src='http://m.weather.com.cn/m/pn12/weather.htm?id=" + GetSysParam("weatherID") + "T' width='245' height='110' marginwidth='0' marginheight='0' hspace='0' vspace='0' frameborder='0' scrolling='no'></iframe>";



        //    //公文公开
        //    if (GetSessionCurrentUserInfo.dic_Hospital != null)
        //    {
        //        list = iBLLOANews.GetList(
        //                         P => ((P.iType == 9) && (P.iflag == 1)
        //                             ),
        //                         P => new
        //                         {
        //                             P.dPublishTime
        //                         },
        //                         new PageModel(1), false);
        //    }
        //    else
        //    {
        //        list = iBLLOANews.GetList(
        //                         P => ((P.iType == 9) && (P.iflag == 1)),
        //                         P => new
        //                         {
        //                             P.dPublishTime
        //                         },
        //                         new PageModel(1), false);
        //    }
        //    temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";
        //    for (int i = 0; i < 3; i++)
        //    {
        //        if (i < list.Count)
        //        {
        //            string gKey = list[i].gKey.ToString();
        //            string url = "addTab(#{Pages},'公文公开' , '/pages/BaseSystem/OANewsManagement/DocumentInfoView.aspx?source=defaultMain&gKey=" + gKey + "','');";
        //            string temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + list[i].sTitle + "\" onclick=\"" + url + "\">" + (list[i].sTitle.Length > 16 ? (list[i].sTitle.Substring(0, 16) + "...") : list[i].sTitle) + "</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">" + (list[i].dPublishTime == null ? "" : ("[" + list[i].dPublishTime.Value.ToString("yyyy-MM-dd") + "]")) + "</td></tr>";
        //            temp_czgg += temp_gg;
        //        }
        //    }
        //    string documentMoreUrl = "addTab(#{Pages},'公文公开' , '/pages/BaseSystem/OANewsManagement/MoreDocumentInfoList.aspx?iType=9','');";
        //    Portlet8.Html = temp_czgg + "</table>";
        //    Portlet8.Title = "<div style=\"color:#000000;float:left;\">公文公开</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + documentMoreUrl + "\">更多</a></div>";






        //    #region 注释掉的公文公开
        //    //公文公开 签发时间倒叙 前五条
        //    //List<Model.oa_OfficialDocument> documentList = iBllOfficialDocument.GetList(p => (p.iFWZT == 3 || p.iFWZT == 5) && p.iSFGK == 1)
        //    //                                                                  .OrderByDescending(p => p.dQFSJ)
        //    //                                                                  .Take(3)
        //    //                                                                  .ToList();
        //    //StringBuilder documentTable = new StringBuilder();
        //    //documentTable.Append("<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>");
        //    //foreach (Model.oa_OfficialDocument item in documentList)
        //    //{
        //    //    string documentTitleurl = "addTab(#{Pages},'公文公开' , '/pages/OAManagement/OfficialDocumentPublic/OfficialDocumentPublicView.aspx?viewMode=Max&&gKey=" + item.gKey.ToString() + "','');";
        //    //    documentTable.Append("<tr>");
        //    //    documentTable.Append("<td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\">");
        //    //    documentTable.Append("<div  class='texthidden' >");
        //    //    documentTable.Append("<img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\">");
        //    //    documentTable.Append("<a class=\"nrbtfont01\" href=\"#\" title=\"");
        //    //    //公文主题
        //    //    documentTable.Append(item.sZT);
        //    //    documentTable.Append("\" onclick=\"" + documentTitleurl + "\">");
        //    //    documentTable.Append(item.sZT.Length > 16 ? (item.sZT.Substring(0, 16) + "...") : item.sZT);
        //    //    documentTable.Append("</a>");
        //    //    documentTable.Append("</div>");
        //    //    documentTable.Append("</td>");
        //    //    documentTable.Append("<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">");
        //    //    documentTable.Append(item.dFWSJ == null ? "" : ("[" + item.dQFSJ.ToString("yyyy-MM-dd") + "]"));
        //    //    documentTable.Append("</td>");
        //    //    documentTable.Append("</tr>");
        //    //}
        //    //documentTable.Append("</table>");
        //    //string documentMoreUrl = "addTab(#{Pages},'公文公开' , '/pages/OAManagement/OfficialDocumentPublic/OfficialDocumentPublicList.aspx','');";
        //    //Portlet8.Title = "<div style=\"color:#000000;float:left;\">公文公开</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + documentMoreUrl + "\">更多</a></div>";
        //    //Portlet8.Html = documentTable.ToString();
        //    #endregion 注释掉的公文公开


        //    #region 注释掉的升级报告
        //    //升级报告
        //    //List<sys_UpdateReport> urlist = iBLLUpReport.GetList(
        //    //        P => (P.iflag == 1), P => new { P.UpdateTime, P.istrik }, new PageModel(1), false
        //    //    );
        //    //temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";
        //    //for (int i = 0; i < 5; i++)
        //    //{
        //    //    if (i < urlist.Count)
        //    //    {
        //    //        string gKey = urlist[i].gKey.ToString();
        //    //        string url = "winer.OpenWin('系统升级报告查看' , '/pages/BaseSystem/UpdateReport/UpdateReportUserView.aspx?gKey=" + gKey + "',800, 400, false, this);";
        //    //        string temp_gg = "";
        //    //        if (urlist[i].istrik == 1)
        //    //        {
        //    //            temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" style=\"color:red;\" href=\"#\" title=\"" + urlist[i].UpdateTime.ToString("yyyy-MM-dd") + "升级报告\" onclick=\"" + url + "\">" + urlist[i].UpdateTime.ToString("yyyy-MM-dd") + "升级报告</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:110px;\" align=\"center\">" + (urlist[i].UpdateTime == null ? "" : ("[" + urlist[i].UpdateTime.ToString("yyyy-MM-dd HH:mm") + "]")) + "</td></tr>";
        //    //        }
        //    //        else
        //    //        {
        //    //            temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + urlist[i].UpdateTime.ToString("yyyy-MM-dd") + "\" onclick=\"" + url + "\">" + urlist[i].UpdateTime.ToString("yyyy-MM-dd") + "升级报告</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:110px;\" align=\"center\">" + (urlist[i].UpdateTime == null ? "" : ("[" + urlist[i].UpdateTime.ToString("yyyy-MM-dd HH:mm") + "]")) + "</td></tr>";
        //    //        }

        //    //        temp_czgg += temp_gg;
        //    //    }
        //    //}
        //    //Portlet7.Html = temp_czgg + "</table>";
        //    //url2 = " addTab(#{Pages},'系统升级报告管理' , '/pages/BaseSystem/UpdateReport/UpdateReportList.aspx?type=true','');";
        //    //Portlet7.Title = "<div style=\"color:#000000;float:left;\">系统升级报告</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + url2 + "\">更多</a></div>";
        //    #endregion 注释掉的升级报告

        //    list = iBLLOANews.GetList(
        //                     P => ((P.iType == 7)
        //                         && (P.iflag == 1)
        //                         //&& (P.bIsAllUnit == true ||
        //                         //P.sys_OANewsTagUnit.Where(Q => Q.gTagUnitKey == res_humanResmodel.gKey)
        //                         //.Count() > 0)
        //                          ),
        //                     P => new
        //                     {
        //                         P.dPublishTime
        //                     },
        //                     new PageModel(1), false);

        //    temp_czgg = "<table border='0' cellspacing='0' cellpadding='0' width='95%' align='center'>";
        //    for (int i = 0; i < 3; i++)
        //    {
        //        if (i < list.Count)
        //        {
        //            string gKey = list[i].gKey.ToString();
        //            string url = "addTab(#{Pages},'系统升级报告' , '/pages/BaseSystem/OANewsManagement/DocumentInfoView.aspx?source=defaultMain&gKey=" + gKey + "','');";
        //            string temp_gg = "<tr><td height='26px' style=\"border-bottom:1px dotted #DDDDDD;\"><div  class='texthidden' ><img src=\"../images/index_41.gif\" border=\"0\" style=\"margin-right:5px;\"><a class=\"nrbtfont01\" href=\"#\" title=\"" + list[i].sTitle + "\" onclick=\"" + url + "\">" + (list[i].sTitle.Length > 16 ? (list[i].sTitle.Substring(0, 16) + "...") : list[i].sTitle) + "</a></div></td>" + "<td style=\"border-bottom:1px dotted #DDDDDD;width:90px;\" align=\"center\">" + (list[i].dPublishTime == null ? "" : ("[" + list[i].dPublishTime.Value.ToString("yyyy-MM-dd") + "]")) + "</td></tr>";
        //            temp_czgg += temp_gg;
        //        }
        //    }
        //    Portlet7.Html = temp_czgg + "</table>";
        //    url2 = "addTab(#{Pages},'系统升级报告列表' , '/pages/BaseSystem/OANewsManagement/MoreDocumentInfoList.aspx?iType=7','');";
        //    Portlet7.Title = "<div style=\"color:#000000;float:left;\">系统升级报告</div><div align=\"right\" style=\"float:right;\"><a class=\"nrbtfont01\" href=\"#\" onclick=\"" + url2 + "\">更多</a></div>";
        //}
        #endregion

        #region 读取webconfig节点
        private string GetConfigByName(string nodeName)
        {
            return System.Configuration.ConfigurationManager.AppSettings[nodeName] == null ? "" : System.Configuration.ConfigurationManager.AppSettings[nodeName];
        }
        #endregion

        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            Session.Clear();
            FormsAuthentication.SignOut();
            Response.Redirect(FormsAuthentication.LoginUrl);
        }
    }
}